% function  CICR_visualizeData(state, algebraic, Time)
% From: http://www.ncbi.nlm.nih.gov/pubmed/15142845
% Title: Computer model of action potential of mouse ventricular myocytes
% Authors: Bondarenko, Szigeti, Bett, Kim, Rasmusson, 2004

% plot state variables 
Ca_i_handle = gcf;
plot(Time, state(:,14)*1000,'r') % index 14 is Ca_i which is [Ca]i = Cytosolic Ca
xlabel('Time [ms]')
ylabel('Ca_i [nM]')


Ca_JSR_fig_handle = figure();
plot(Time, state(:,11)/1000,'b'); %Ca_JSR
xlabel('Time [ms]')
ylabel('Ca_JSR [mM]')

Ca_NSR_fig_handle = figure();
plot(Time, state(:,12)/1000,'b'); %Ca_NSR
xlabel('Time [ms]')
ylabel('Ca_NSR [mM]')


NCX_Current_fig_handle = figure();
plot(Time,algebraic(:,2)) % NCX Current'
xlabel('Time [ms]')
ylabel('NCX Current  [uA/uF]')

% PMCA_Current_fig_handle = figure();
hold on
plot(Time,algebraic(:,3),'r') % PMCA Current
xlabel('Time [ms]')
% ylabel('PMCA Current  [uA/uF]')
ylabel('[uA/uF]')
legend('NCX Current','PMCA Current')

% backgroundCa_Current_fig_handle = figure();
% plot(Time,algebraic(:,4)) % Background Ca Current
% xlabel('Time [ms]')
% ylabel('Background Ca Current  [uA/uF]')

I_CaL_fig_handle = figure();
plot(Time,algebraic(:,1)) % I_CaL (L-type Ca Current)
xlabel('Time [ms]')
% ylabel('The function $\int f(\theta) d\theta$','FontSize',20,'Interpreter','latex');
ylabel('L-type Ca Current  [uA/uF]')


I_CaT_fig_handle= figure();
plot(Time,algebraic(:,5)) % I_CaT
xlabel('Time [ms]')
ylabel('T-type Ca Current  [uA/uF]')



J_rel_fig_handle = figure();
plot(Time,algebraic(:,6)) % J_rel : Release Ca Flux
xlabel('Time [ms]')
ylabel('Release Ca Flux  [mol/(s*m^3)]')

J_up_fig_handle = figure();
plot(Time,algebraic(:,7)) %  J_up : Uptake Ca Flux
xlabel('Time [ms]')
ylabel('Uptake Ca Flux [mol/(s*m^3)]')

V_m_fig_handle = figure();
plot(Time,algebraic(:,8)) % V_m - membrane voltage
xlabel('Time [ms]')
ylabel('Membrane Voltage [mV]')
zoom = 1.1;
axis([min(Time)  max(Time)  min(algebraic(:,8)) * zoom  max(algebraic(:,8)) * zoom])

figure()
plot(Time,state(:,6)  ,'b'); % RyR Open probability
xlabel('Time [ms]')
ylabel('RyR Open Probability (blue)')

hold on
 
% plot(Time, state(:,13)*1000,'r') % Ca_ss  - [Ca] in subspace
% xlabel('Time [ms]')
% ylabel('Ca_{ss} [nM]')